#include "MessageQueryer.h"


MessageQueryer::MessageQueryer(void)
	:m_bMouseLeftButtonPress(false)
	,m_bMouseRightButtonPress(false)
{
}


MessageQueryer::~MessageQueryer(void)
{
}

MessageQueryer* MessageQueryer::Instance()
{
	static MessageQueryer* instance = NULL;
	if(!instance)
		instance = new MessageQueryer();
	return instance;
}

bool MessageQueryer::MouseLeftButtonIsPress()
{
	return m_bMouseLeftButtonPress;
}

bool MessageQueryer::MouseRightButtonIsPress()
{
	return m_bMouseRightButtonPress;
}

void MessageQueryer::SetMouseLeftButton( bool state )
{
	m_bMouseLeftButtonPress = state;
}

void MessageQueryer::SetMouseRightButton( bool state )
{
	m_bMouseRightButtonPress = state;
}

void MessageQueryer::MouseUpdate( MouseMsg msg,const Point& oldPoint,const Point& currPoint )
{
	switch(msg)
	{
	case MMsg_LeftButtonDown:
		SetMouseLeftButton(true);
		break;;

	case MMsg_LeftButtonUp:
		SetMouseLeftButton(false);
		break;

	case MMsg_RightButtonDown:
		SetMouseRightButton(true);
		break;

	case MMsg_RightButtonUp:
		SetMouseRightButton(false);
		break;
	}
}

void MessageQueryer::Init()
{
	MouseSubject::Instance()->AddMouseListener(this);
}
